<template>
	<view class="enterprise-warning-control-detail">
		<titleName :name="name" :backShow="true"></titleName>

		<view class="warning-detail-wrap">
			<view :class="msgObj.colorlevel==1?'red':msgObj.colorlevel==2?'orange':msgObj.colorlevel==3?'yellow':''">
			</view>
			<view class="publish-content">
				<view class="title">
					{{msgObj.colorlevel==1?'红色预警（I级）':msgObj.colorlevel==2?'橙色预警（II级）':msgObj.colorlevel==3?'黄色预警（III级）':''}}
				</view>
				<view class="publisher">
					<image :src="resourceUrl+'login-huanbao-bgc.png'" mode=""></image>
					<view class="content">
						<view class="name">{{msgObj.publisher}}</view>
						<view class="publish-time">
							<view class="publish">发布</view>
							<view class="time">{{msgObj.publishdate}}</view>
						</view>
					</view>
				</view>
				<view class="control-time">启警时间：{{msgObj.monitortimestr}}</view>
			</view>

			<!-- <view class="measure">
				<view class="title">
					<view class="line"></view>
					<view class="name">减排措施</view>
				</view>
				<view class="content" v-html="msgObj.content">

				</view>
			

			</view> -->
			<view class="publish-message-wrap">
				<view class="publish-msg">
					当前预警级别为<text
						class="">{{msgObj.colorlevel == 1 ? "红色预警": msgObj.colorlevel == 2? "橙色预警": msgObj.colorlevel == 3? "黄色预警": ""}}</text>

					,执行 <text>{{ msgObj.colorlevel == 1
          ? "红色预警"
          : msgObj.colorlevel == 2
          ? "橙色预警"
          : msgObj.colorlevel == 3
          ? "黄色预警"
          : ""}}</text> 应急响应措施，启动时间 <text>{{ splitDate(msgObj.monitorstarttime).y}}</text> 年
					<text>{{ splitDate(msgObj.monitorstarttime).m }}</text>
					月 <text>{{ splitDate(msgObj.monitorstarttime).d }}</text>日
					<text>{{ splitDate(msgObj.monitorstarttime).h }}</text> 时,我单位于
					<text>{{ splitDate(msgObj.publishdate).m }}</text> 月
					<text>{{ splitDate(msgObj.publishdate).d }}</text> 日
					<text>{{ splitDate(msgObj.publishdate).h >= 10
          ? splitDate(msgObj.publishdate).h
          : splitDate(msgObj.publishdate).h?.split("")[1] }}</text>
					时接到应急管控通知 <text class="text"
						v-if="msgObj.followflag == 1">，于<text>{{ splitDate(msgObj.followtime).m }}</text>月
						<text>{{ splitDate(msgObj.followtime).d }}</text> 日<text>{{
          splitDate(msgObj.followtime).h >= 10
            ? splitDate(msgObj.followtime).h
            : splitDate(msgObj.followtime).h?.split("")[1]
        }}</text>时管控措施落实到位。</text>

				</view>
				<view class="list">
					<view class="item" v-if="dataList?.length>0">
						<view
							:class="[msgObj.colorlevel==1?'red':msgObj.colorlevel==2?'orange':msgObj.colorlevel==3?'yellow':'','name']">
							生产线/工序</view>

						<view
							:class="[msgObj.colorlevel==1?'red':msgObj.colorlevel==2?'orange':msgObj.colorlevel==3?'yellow':'','val']">
							减排措施</view>
					</view>
					<view
						:class="['item',msgObj.colorlevel==1?'red':msgObj.colorlevel==2?'orange':msgObj.colorlevel==3?'yellow':'']"
						v-for="item in dataList" :key="item.id">
						<view :class="['name']">
							{{item.processname}}

						</view>
						<view class="color" style="overflow: hidden;"></view>
						<view class="val">

							{{item['measure'+msgObj.colorlevel]}}

						</view>
					</view>

				</view>
				<view class="undertaking" v-if="usertype!=9">
					<button class="btn" v-if="userno==1"
						@click="jumpUndertaking(msgObj.noticeFollow.promisetime1,msgObj.noticeFollow.promisetime2)">{{ promiseattachurl1?'已签署':'签署承诺书'}}</button><button
						class="btn" v-if="userno==2"
						@click="jumpUndertaking(msgObj.noticeFollow.promisetime1,msgObj.noticeFollow.promisetime2)">{{ promiseattachurl2?'已签署':'签署承诺书'}}</button>
				</view>
				<view class="undertaking" v-if="usertype==9">
					<button class="btn" @click="searchSignatureList">查看承诺书</button>
				</view>

				<view class="btn-wrap" v-if="usertype !=9 && computedTimeFlag">
					<button class="btn"
						@click="execute(msgObj.followstatus)">{{msgObj.followstatus==1?'已执行':msgObj.followstatus==2?'已驳回':msgObj.followstatus==3?'已通过':'立即执行'}}</button>
				</view>
				<view class="btn-wrap" v-if="usertype ==9">
					<button class="btn"
						disabled>{{msgObj.followstatus==1?'已执行':msgObj.followstatus==2?'已驳回':'未执行'}}</button>
				</view>
			</view>

		</view>

	</view>


</template>

<script setup>
	import titleName from '../../components/titleName.vue'
	import http from '../../request/index.js'
	import {
		resourceUrl
	} from '../../request/config'
	import {
		onLoad
	} from '@dcloudio/uni-app'
	import {
		ref
	} from 'vue'
	import dayjs from 'dayjs'
	let detail = ref({})
	let id = ref('')
	let usertype = ref('')
	let value = ref('0')
	let dataList = ref([])
	let userno = ref('')
	let selVal = ref(2)
	let fielNameList = ref([{}])
	let fielUrlList = ref([])
	let msgObj = ref({})
	let name = "企业管控详情"
	let promiseattachurl1 = ref('')
	let promiseattachurl2 = ref('')
	let change = () => {}
	let computedTimeFlag = ref(false)
	let enterpriseid = ref('')
	let splitDate = (str) => {
		if (!str) return "";
		let date = str.split(" ");
		let getDate = /(\d{4})-(\d{2})-(\d{2})/.exec(date[0]);
		let time = /(\d{2}):(\d{2}):(\d{2})/.exec(date[1]);
		return {
			y: getDate[1],
			m: getDate[2],
			d: getDate[3],
			h: time[1],
			minute: time[2] >= 10 ? time[2] : time[2].split('')[1],
			s: time[3],
		};
	};
	let execute = (status) => {
		if (msgObj.value.followstatus == 2) {
			uni.redirectTo({
				url: `/messagePageOther/enterprisecontrolexaminedetail/index?examineFlag=1&id=${msgObj.value.id}`
			})
		} else {
			uni.redirectTo({
				url: `/homePageOther/execute/index?id=${msgObj.value.id}&colorlevel=${msgObj.value.colorlevel}&monitortimestr=${msgObj.value.monitortimestr}&enterprise=${msgObj.value.lstEnterpriseMeasure[0].fld1}&followstatus=${msgObj.value.followstatus}&followattachurl=${msgObj.value.noticeFollow.followattachurl}`
			})
		}


		// http({
		// 	url: "/greenNotice/sayFollow",
		// 	data: {
		// 		id: id.value
		// 	}
		// }).then((res) => {
		// 	if (res.code == 0) {
		// 		uni.showToast({
		// 			title: '执行成功',
		// 			icon: 'none',
		// 			duration: 1500
		// 		})

		// 		setTimeout(() => {
		// 			uni.navigateBack()
		// 		}, 1500)

		// 	}
		// })
	}
	let searchSignatureList = () => {


		uni.navigateTo({
			url: `/homePageOther/signaturelist/index?enterpriseid=${enterpriseid.value}`
		})
	}
	let jumpUndertaking = (promisetime1, promisetime2) => {


		uni.redirectTo({
			url: `/homePageOther/undertaking/index?id=${id.value}&promiseattachurl1=${promiseattachurl1.value}&promiseattachurl2=${promiseattachurl2.value}&promisetime1=${promisetime1}&promisetime2=${promisetime2}`
		})
	}
	onLoad((e) => {
		console.log(e, 'e');
		enterpriseid.value = e.enterpriseid
		id.value = e.id
		usertype.value = uni.getStorageSync('usertype')
		userno.value = uni.getStorageSync('userno')
		if (usertype.value != 9) {
			http({
				url: "/greenNotice/detail",
				data: {
					id: e.id,
				}
			}).then((res) => {
				if (res.code == 0) {
					dataList.value = res.data.lstEnterpriseMeasure
					msgObj.value = res.data
					promiseattachurl1.value = msgObj.value.noticeFollow.promiseattachurl1
					promiseattachurl2.value = msgObj.value.noticeFollow.promiseattachurl2
					let monitortimestr = dayjs(res.data.monitorstarttime).valueOf()
					// console.log(monitortimestr, new Date().getTime());
					if (new Date().getTime() > monitortimestr) {
						computedTimeFlag.value = true
					}

				}
			})
		} else {
			http({
				url: "/greenAdmNotice/getRecvEnterpriseNoticeDetail",
				data: {
					noticeid: e.id,
					enterpriseid: e.enterpriseid
				}
			}).then((res) => {
				if (res.code == 0) {
					dataList.value = res.data.notice.lstEnterpriseMeasure
					msgObj.value = res.data.notice

				}
			})
		}

	})
</script>

<style lang="scss" scoped>
	:deep(.uni-select) {

		font-family: Source Han Sans CN;
		font-weight: 400;
		font-size: 25rpx;
		color: #333333;
		padding: 0;
		border: none;
	}

	:deep(.uni-select__input-box) {

		font-family: Source Han Sans CN;
		font-weight: 400;
		font-size: 25rpx;
		color: #333333;

	}

	:deep(.uni-icons) {
		font-size: 34upx !important;
	}

	:deep(.uni-select__selector) {
		width: 130upx;
	}

	:deep(.ph-color) {


		font-family: Source Han Sans CN;
		font-weight: 400;
		font-size: 24rpx;
		color: #999999;


	}

	.enterprise-warning-control-detail {
		width: 100vw;
		height: 100vh;
		overflow: hidden;
		background: #F3F5F7;

		.control-enterprise {
			.list {
				height: calc(100vh - 160upx - 103upx - 67upx - 21upx - 68upx);
				width: 100vw;
				overflow: scroll;
				padding: 0 22upx 0upx 22up;

				.item:first-child {
					margin-top: 0upx !important;
				}

				.item {
					margin-top: 30upx;
					background: #fff;
					width: 100%;
					padding-left: 40upx;
					padding-top: 32upx;
					padding-bottom: 40upx;
					height: 100%;

					.enterprise-name {

						font-family: Source Han Sans CN;
						font-weight: 500;
						font-size: 31rpx;
						color: #222222;

					}

					.inform-status {

						font-family: Source Han Sans CN;
						font-weight: 400;
						font-size: 28rpx;
						color: #666666;
						margin: 30upx 0 28upx 0;

					}

					.top-appear {
						display: flex;
						align-items: center;

						.name {

							font-family: Source Han Sans CN;
							font-weight: 400;
							font-size: 28rpx;
							color: #666666;

						}

						.val {
							width: 79rpx;
							height: 35rpx;
							background: rgb(206, 227, 254);
							border-radius: 7rpx;

							font-family: Source Han Sans CN;
							font-weight: 500;
							font-size: 19rpx;
							color: #0874FA;
							line-height: 35rpx;
							text-align: center;


						}
					}

					.phone {
						margin-top: 30upx;
						font-family: Source Han Sans CN;
						font-weight: 400;
						font-size: 28rpx;
						color: #666666;

					}

					.person {
						margin: 33upx 0;
						font-family: Source Han Sans CN;
						font-weight: 400;
						font-size: 28rpx;
						color: #666666;

					}

					.address {

						font-family: Source Han Sans CN;
						font-weight: 400;
						font-size: 28rpx;
						color: #666666;

					}
				}
			}

			.total-num {
				height: 68upx;
				line-height: 68upx;
				padding-left: 30upx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				font-size: 23rpx;
				color: #333333;

				text {
					color: #0874FA;
				}
			}

			.search-wrap {
				width: 750rpx;

				margin-top: 21upx;
				display: flex;
				align-items: center;
				justify-content: center;

				.ipt-wrap {
					display: flex;
					width: 690rpx;
					height: 67rpx;
					background: #fff;
					border-radius: 38rpx;
					padding-left: 34upx;
					align-items: center;

					.line {
						width: 1rpx;
						height: 35rpx;
						background: #E8E8E8;
						margin-left: 19upx;
					}

					input {
						flex-grow: 1;
						padding-right: 100upx;
						padding-left: 30upx;
						height: 67upx;
						font-size: 28upx;
					}



					.btn {
						flex-shrink: 0;
						width: 112rpx;
						height: 67rpx;
						background: #0874FA;
						border-radius: 14rpx;
						line-height: 67upx;
						font-weight: 500;
						font-size: 31rpx;
						color: #FFFFFF;
					}
				}

			}
		}

		.warning-detail-wrap {
			height: 280upx;

			.red {
				background: #FF0000;
				height: 20upx;
			}

			.orange {
				height: 20upx;
				background: #FF9000;
			}

			.yellow {
				height: 20upx;
				background: #FFCC00;
			}



			.publish-message-wrap {
				padding: 32upx 26upx 0 26upx;
				height: calc(100vh - 160upx - 268upx - 30upx);
				padding-bottom: 100upx;
				overflow: scroll;
				margin-top: 10upx;
				background-color: #fff;

				.undertaking {
					padding: 100upx 22upx 0upx 22upx;

					.btn {
						width: 100%;
						height: 87rpx;
						border-radius: 43rpx;
						background: #00A096;
						border-radius: 43rpx;
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 31rpx;
						color: #FFFFFF;
						line-height: 87rpx;
						text-align: center;
					}
				}

				.btn-wrap {

					padding: 30upx 22upx 0upx 22upx;

					.btn {
						width: 100%;
						height: 87rpx;
						background: #0874FA;
						border-radius: 43rpx;

						font-family: PingFang SC;
						font-weight: 500;
						font-size: 31rpx;
						color: #FFFFFF;
						line-height: 87rpx;
						text-align: center;
					}
				}

				.list {
					margin-top: 30upx;

					.item:first-child {
						margin-top: 0upx;

						.name {
							width: 258rpx;
							height: 86rpx;


							font-family: Source Han Sans CN;
							font-weight: 500;
							font-size: 34rpx;
							color: #FFFFFF;
							line-height: 86rpx;
						}



						.val {
							width: 429rpx;
							height: 86rpx;
							background: #FFCC00;


						}

						.val.red {
							color: #FFFFFF;
							background: #FF0000;
						}

						.val.orange {
							color: #FFFFFF;
							background: #FF9000;
						}

						.val.yellow {
							color: #FFFFFF;
							background: #FFCC00;
						}
					}

					.item.red {
						background: #FF0000;
						color: #000000;
					}

					.item.orange {
						background: #FF9000;
						color: #000000;
					}

					.item.yellow {
						color: #000000;
						background: #FFCC00;
					}

					.item {
						display: flex;
						align-items: stretch;
						justify-content: space-between;
						margin-top: 6upx;
						height: auto;

						.color {
							background-color: #fff;
							width: 12upx;
							height: auto;
						}

						.name {
							width: 258rpx;
							padding: 20upx;
							font-family: Source Han Sans CN;
							font-weight: 500;
							font-size: 34rpx;
							color: #000000;
							height: auto;
							display: flex;
							align-items: center;
							justify-content: center;

						}



						.val {
							display: flex;
							align-items: center;
							justify-content: center;
							width: 429rpx;
							height: auto;
							padding: 20upx;
							font-family: Source Han Sans CN;
							font-weight: 500;
							font-size: 34rpx;
							color: #000000;

						}


					}
				}

				.publish-msg {
					width: 100%;
					height: 200rpx;
					border-radius: 21rpx;
					border: 1px dashed #D61619;
					// display: flex;
					// justify-content: center;
					// align-items: center;
					text-indent: 2em;
					padding: 30upx 20upx;


					font-family: Source Han Sans CN;
					font-weight: 400;
					font-size: 24rpx;
					color: #000000;
					line-height: 38rpx;

					text:not(.text) {
						color: #D61619;
					}

					// text {

					// }

				}
			}

			.measure {
				margin-top: 10upx;
				padding-top: 38upx;
				background-color: #fff;
				padding-bottom: 100upx;
				height: calc(100vh - 160upx - 259upx - 10upx);
				overflow: scroll;




				.content {
					padding-left: 32upx;
					margin-top: 37upx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					font-size: 29rpx;
					color: #333333;
					line-height: 52rpx;
					padding-right: 20upx;
				}

				.title {
					display: flex;
					align-items: center;
					padding-left: 30upx;

					.line {
						width: 8rpx;
						height: 29rpx;
						background: #0874FA;
						border-radius: 4rpx;
						margin-right: 12upx;
					}

					.name {

						font-family: Source Han Sans CN;
						font-weight: bold;
						font-size: 29rpx;
						color: #000000;

					}
				}
			}

			.enterprise-statis {
				margin-top: 19upx;
				width: 100vw;
				padding: 0 26upx 0 26upx;


				.wrap {
					width: 100%;
					height: 164rpx;
					background: #FFFFFF;
					border-radius: 21rpx;
					display: flex;
					justify-content: space-between;
					padding: 0 65upx;
					align-items: center;

					.control-num,
					.execute,
					.no-execute {
						display: flex;
						flex-direction: column;

						.name {

							font-family: Source Han Sans CN;
							font-weight: 400;
							font-size: 23rpx;
							color: #666666;

						}

						.val {
							margin-top: 15upx;
							font-family: FZTanHeiS-B-GB;
							font-weight: 400;
							font-size: 35rpx;
							color: #333333;

						}
					}



					.execute {



						.val {
							margin-top: 15upx;

							font-family: FZTanHeiS-B-GB;
							font-weight: 400;
							font-size: 35rpx;
							color: #0874FA;

						}
					}

					.no-execute {



						.val {
							margin-top: 15upx;

							font-family: FZTanHeiS-B-GB;
							font-weight: 400;
							font-size: 35rpx;
							color: #FF0000;

						}
					}
				}
			}

			.publish-content {
				width: 750rpx;
				padding-right: 20upx;
				background-color: #fff;
				padding-left: 30upx;
				padding-top: 30upx;
				padding-bottom: 30upx;

				.title {

					font-family: Source Han Sans CN;
					font-weight: bold;
					font-size: 35rpx;
					color: #070707;

				}

				.control-time {
					margin-top: 30upx;

					font-family: Source Han Sans CN;
					font-weight: 400;
					font-size: 28rpx;
					color: #333333;

				}

				.publisher {
					display: flex;
					align-items: center;
					margin-top: 35upx;

					image {
						width: 55upx;
						height: 55upx;
						margin-right: 10upx;
					}

					.content {
						.name {

							font-family: Source Han Sans CN;
							font-weight: 500;
							font-size: 24rpx;
							color: #070707;

						}

						.publish-time {
							display: flex;
							align-items: center;

							.publish {
								width: 48rpx;
								height: 23rpx;
								background: #EEF2FF;
								border-radius: 6rpx;
								line-height: 23upx;
								text-align: center;
								font-family: Source Han Sans CN;
								font-weight: 500;
								font-size: 14rpx;
								color: #0874FA;
								margin-right: 7upx;

							}

							.time {

								font-family: Source Han Sans CN;
								font-weight: 400;
								font-size: 22rpx;
								color: #999999;

							}
						}
					}
				}
			}
		}

		.sel-wrap {
			width: 750rpx;
			height: 103rpx;
			background: #FFFFFF;
			display: flex;
			align-items: center;
			padding: 0 153upx;
			justify-content: space-between;


			.warning-detail {
				position: relative;

				.name {
					font-family: Source Han Sans CN;
					font-weight: 400;
					font-size: 28rpx;
					color: #666666;

				}

				.active {

					font-family: Source Han Sans CN;
					font-weight: bold !important;
					font-size: 28rpx !important;
					color: #000000 !important;

				}

				.line {
					width: 48rpx;
					height: 8rpx;
					background: #0874FA;
					border-radius: 4rpx;
					position: absolute;
					bottom: -10upx;
					left: 50%;
					transform: translateX(-50%);
				}
			}

			.control-enterprise {
				position: relative;

				.name {
					font-family: Source Han Sans CN;
					font-weight: 400;
					font-size: 28rpx;
					color: #666666;

				}

				.active {

					font-family: Source Han Sans CN;
					font-weight: bold !important;
					font-size: 28rpx !important;
					color: #000000 !important;

				}

				.line {
					width: 48rpx;
					height: 8rpx;
					background: #0874FA;
					border-radius: 4rpx;
					position: absolute;
					bottom: -10upx;
					left: 50%;
					transform: translateX(-50%);
				}
			}
		}




	}
</style>